﻿
@{
    ViewBag.Title = "FireOperateFormAdd";
    Layout = "~/Views/Shared/_LayoutMain.cshtml";
}

@section css{
    <link href="~/Assets/css/lib/fileinput.css" rel="stylesheet" />
    <link href="~/Assets/css/lib/bootstrap-datetimepicker.min.css" rel="stylesheet" />
    <link href="~/Assets/css/lib/bootstrap-select.css" rel="stylesheet" />
    <style>
        #location {
            position: absolute;
            z-index: 100;
            width: 10px;
            height: 10px;
            color: red;
            font-weight: bold;
        }

        .div-relative {
            position: relative;
        }

        .div-a {
            position: absolute;
        }
    </style>
}

<header id="topbar">
    <div class="topbar-left">
        <ol class="breadcrumb">
            <li class="crumb-active">
                <a>动火申请</a>
            </li>
            <li class="crumb-link">
                <a>动火管理</a>
            </li>
            <li class="crumb-link">
                <a>施工作业</a>
            </li>
            <li class="crumb-trail">动火申请</li>
        </ol>
    </div>
</header>
<div id="content" ng-cloak ng-controller="ConstructionController" ng-init="
     page='@(Request.QueryString["page"].IsEmpty() ? "1" : Request.QueryString["page"])';
     AddModel.ApplyDate='@DateTime.Now.ToString("yyyy-MM-dd")';
     BindDepartmentList('Dep_Select',User.DepartmentId);
     BindDepartmentList('LocalDep_Select');
     AddModel.DepartmentId=User.DepartmentId;
     AddModel.FactoryAreaId='1';
     GetConstructionCompany('Company_Select');

     GetLocationList(AddModel.FactoryAreaId,'Location_Select');
     AddModel.LevelId='3';
     GetConstructionList();
     GetFireOperateLevel();
     GetFireOperateType();
     GetFireOperateSolution();
    GetFireOperateWorker('Worker_Select');
     ">
    <div class="load" ng-show="DataLoading">
        <div class="loader">
            <svg version="1.1" id="loader-1" x="0px" y="0px" width="100px" height="100px" viewBox="0 0 50 50" style="enable-background:new 0 0 50 50;" xml:space="preserve">
            <path fill="#000" d="M43.935,25.145c0-10.318-8.364-18.683-18.683-18.683c-10.318,0-18.683,8.365-18.683,18.683h4.068c0-8.071,6.543-14.615,14.615-14.615c8.072,0,14.615,6.543,14.615,14.615H43.935z">
            <animateTransform attributeType="xml" attributeName="transform" type="rotate" from="0 25 25" to="360 25 25" dur="0.6s" repeatCount="indefinite" />
			</path>
		</svg>
            <div class="load-msg">正在加载</div>
        </div>
    </div>
    <div class="row">
        <div class="col-md-12">
            <div class="panel panel-info panel-border top mb35">
                <div class="panel-heading">
                    <span class="panel-title">动火作业申请</span>
                </div>
                <div class="panel-body">
                    <form class="form-horizontal" role="form">
                        <div class="form-group">
                            <label class="col-sm-1 control-label"><b style="color:red;">*</b>关联施工作业</label>
                            <div class="col-sm-9">
                                <table class="table table-striped table-bordered table-hover">
                                    <thead>
                                        <tr>
                                            <th style="width:5%">序号</th>
                                            <th style="width:10%">单号</th>
                                            <th style="width:20%">项目名称</th>
                                            <th style="width:20%">施工内容</th>
                                            <th style="width:20%">涉及危险作业</th>
                                            <th style="width:20%">施工时间</th>
                                            <th style="width:10%">申请人</th>
                                            <th style="width:10%">操作</th>
                                        </tr>
                                    </thead>
                                    <tbody>
                                        <tr ng-show="ConstructionList.length==0">
                                            <td colspan="8" style="text-align:center;vertical-align:middle;line-height:30px;">没有数据</td>
                                        </tr>
                                        <tr ng-repeat="x in ConstructionList">
                                            <td ng-bind="$index+1"></td>
                                            <td ng-bind="x.FormNo"></td>
                                            <td ng-bind="x.ProjectName"></td>
                                            <td ng-bind="x.Content"></td>
                                            <td ng-bind="x.TypeList"></td>
                                            <td>{{x.StartTime|JSONDate:'yyyy-MM-dd'}} ~ {{x.EndTime|JSONDate:'yyyy-MM-dd'}}</td>
                                            <td>{{x.CreateUserName}}({{x.CreateUser}})</td>
                                            <td>
                                                <a ng-click="SelectConstructionForm(x)" class="btn btn-primary btn-xs btn-label"><i class="fa fa-check-circle-o"></i>选择</a>
                                            </td>
                                        </tr>
                                    </tbody>
                                </table>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-1 control-label"><b style="color:red;">*</b>施工单号</label>
                            <div class="col-sm-4">
                                <input type="text" class="form-control" placeholder="施工单号..." ng-model="AddModel.ConstructionFormNo" disabled>
                            </div>
                            <label class="col-sm-1 control-label"><b style="color:red;">*</b>所在厂区</label>
                            <div class="col-sm-4">
                                <select class="form-control" ng-model="AddModel.FactoryAreaId" ng-change="GetLocationList(AddModel.FactoryAreaId,'Location_Select');">
                                    <option value="" selected>选择所在厂区</option>
                                    <option value="1">浦东</option>
                                    <option value="2">大场</option>
                                </select>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-1 control-label">申请部门</label>
                            <div class="col-sm-4">
                                <select id="Dep_Select" class="selectpicker show-tick form-control" ng-model="AddModel.DepartmentId" data-live-search="true" ng-change="refreshOption('Dep_Select');" disabled>
                                    <option value="" selected>选择申请部门</option>
                                </select>
                            </div>
                            <label class="col-sm-1 control-label">申请人</label>
                            <div class="col-sm-4">
                                <input type="text" class="form-control" placeholder="详细位置..." ng-model="User.UserName" disabled>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-1 control-label">项目名称</label>
                            <div class="col-sm-9">
                                <input type="text" class="form-control" placeholder="项目名称..." ng-model="AddModel.ProjectName" disabled>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-1 control-label">申请日期</label>
                            <div class="col-sm-4">
                                <input type="text" class="form-control" placeholder="详细位置..." ng-model="AddModel.ApplyDate" disabled>
                            </div>
                            <label class="col-lg-1 control-label"><b style="color:red;">*</b>施工单位</label>
                            <div class="col-lg-3">
                                <select id="Company_Select" class="selectpicker show-tick form-control" ng-model="AddModel.CompanyId" data-live-search="true" ng-change="refreshOption('Company_Select');">
                                    <option value="" selected>选择施工单位</option>
                                </select>
                            </div>
                            <div class="col-lg-1">
                                <a class="btn btn-primary" data-toggle="modal" href="#AddModal">添加施工单位</a>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-lg-1 control-label"><b style="color:red;">*</b>动火项目</label>
                            <div class="col-lg-9">
                                <textarea class="form-control" rows="3" ng-model="AddModel.Content" ng-init="AddModel.Content==''"></textarea>
                            </div>
                        </div>
                        <div class="form-group" ng-repeat="x in LocationModel">
                            <label class="col-lg-1 control-label">动火地点 {{$index+1}}</label>
                            <div class="col-lg-2">
                                <select id="Location_Select_{{$index}}" class="selectpicker show-tick form-control" ng-model="x.LocationId" data-live-search="true" ng-change="refreshOption('Location_Select'+$index);">
                                    <option value="" selected>选择动火地点</option>
                                </select>
                            </div>
                            <div class="col-lg-2">
                                <input type="text" class="form-control" placeholder="详细位置..." ng-model="x.LocationDetail">
                            </div>
                            <label class="col-lg-1 control-label">施工坐标</label>
                            <div class="col-lg-1">
                                <input type="text" class="form-control" ng-model="x.X" readonly />
                            </div>
                            <div class="col-lg-1">
                                <input type="text" class="form-control" ng-model="x.Y" readonly />
                            </div>
                            <div class="col-lg-1">
                                <a href="#MapModal" data-toggle="modal" ng-click="GetCurrentLocationModel(x);" class="btn btn-info">选择坐标</a>
                            </div>
                            <div class="col-lg-1" ng-if="$index>0">
                                <button class="btn btn-warning" ng-click="RemoveLocationItem(x,LocationModel)">移除</button>
                            </div>
                            <div class="col-lg-1" ng-if="$index==0">
                                <button class="btn btn-primary" ng-click="InitLocationModel(LocationModel,AddModel)">添加施工位置</button>
                            </div>
                        </div>
                        @*<div class="form-group">
                                <label class="col-lg-1 control-label"><b style="color:red;">*</b>动火地点</label>
                                <div class="col-lg-4">
                                    <select id="Location_Select" class="selectpicker show-tick form-control" ng-model="AddModel.LocationId" data-live-search="true" ng-change="refreshOption('Location_Select');">
                                        <option value="" selected>选择动火地点</option>
                                    </select>
                                </div>
                                <label class="col-lg-1 control-label"><b style="color:red;">*</b>详细位置</label>
                                <div class="col-lg-2">
                                    <input type="text" class="form-control" placeholder="详细位置..." ng-model="AddModel.LocationDetail">
                                </div>

                                <div class="col-lg-1">
                                    <input type="text" class="form-control" placeholder="X" ng-model="AddModel.X" readonly>
                                </div>

                                <div class="col-lg-1">
                                    <input type="text" class="form-control" placeholder="Y" ng-model="AddModel.Y" readonly>
                                </div>
                                <div class="col-lg-1">
                                    <a href="#MapModal" data-toggle="modal" ng-click="" class="btn btn-info">选择坐标</a>
                                </div>
                            </div>*@
                        <div class="form-group">
                            <label class="col-lg-1 control-label"><b style="color:red;">*</b>动火级别</label>
                            <div class="col-lg-4">
                                <select class="form-control" ng-model="AddModel.LevelId">
                                    <option class="form-control" ng-repeat="x in LevelList" value="{{x.Id}}">{{x.LevelName}}</option>
                                </select>
                            </div>
                            <label class="col-lg-1 control-label"><b style="color:red;">*</b>动火类别</label>
                            <div class="col-lg-4">
                                <label class="checkbox-inline" ng-repeat="x in TypeList">
                                    <input type="checkbox" id="chk_type_{{x.TypeId}}" name="IsPublic"> {{x.TypeName}}
                                </label>
                                <input type="text" id="txt_type_{{x.TypeId}}" ng-model="AddModel.OtherType" style="width:50px;border:none;border-bottom:1px solid grey;" />
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-lg-1 control-label"><b style="color:red;">*</b>动火人</label>
                            <div class="col-lg-8">
                                <select id="Worker_Select" class="selectpicker show-tick form-control" ng-model="AddModel.FireOperateId" data-live-search="true" multiple ng-change="refreshOption('Worker_Select');">
                                </select>
                            </div>
                            <div class="col-lg-1">
                                <a class="btn btn-primary" data-toggle="modal" href="#AddFireOperator">添加动火人</a>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-lg-1 control-label">施工单位<br /><b style="color:red;">*</b>监护人</label>
                            <div class="col-lg-4">
                                <input type="text" class="form-control" placeholder="施工单位监护人..." ng-model="AddModel.CompanyManager">
                            </div>
                            <label class="col-lg-1 control-label"><b style="color:red;">*</b>联系方式</label>
                            <div class="col-lg-4">
                                <input type="text" class="form-control" placeholder="施工单位监护人联系方式..." ng-model="AddModel.CompanyManagerPhone">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-lg-1 control-label"><b style="color:red;">*</b>施工单位现场<br />负责人</label>
                            <div class="col-lg-4">
                                <input type="text" class="form-control" placeholder="施工单位现场负责人..." ng-model="AddModel.Reponsible">
                            </div>
                            <label class="col-lg-1 control-label"><b style="color:red;">*</b>联系方式</label>
                            <div class="col-lg-4">
                                <input type="text" class="form-control" placeholder="施工单位现场负责人联系方式..." ng-model="AddModel.Phone">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-lg-1 control-label"><b style="color:red;">*</b>申请部门现场<br />监护人</label>
                            <div class="col-lg-4">
                                <input type="text" class="form-control" placeholder="申请部门现场监护人..." ng-model="AddModel.ApplyDepContract">
                            </div>
                            <label class="col-lg-1 control-label"><b style="color:red;">*</b>联系方式</label>
                            <div class="col-lg-4">
                                <input type="text" class="form-control" placeholder="申请部门现场监护人联系方式..." ng-model="AddModel.ApplyDepPhone">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-lg-1 control-label"><b style="color:red;">*</b>属地部门联系人</label>
                            <div class="col-lg-2">
                                <select id="LocalDep_Select" class="selectpicker show-tick form-control" ng-model="AddModel.LocalDepId" data-live-search="true" ng-change="refreshOption('LocalDep_Select');">
                                    <option value="" selected>选择属地部门</option>
                                </select>
                            </div>
                            <div class="col-lg-2">
                                <input type="text" class="form-control" placeholder="属地联系人..." ng-model="AddModel.LocalDepContract">
                            </div>
                            <label class="col-lg-1 control-label"><b style="color:red;">*</b>联系方式</label>
                            <div class="col-lg-4">
                                <input type="text" class="form-control" placeholder="属地联系人联系方式..." ng-model="AddModel.LoalDepPhone">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-lg-1 control-label"><b style="color:red;">*</b>有效期开始时间</label>
                            <div class="col-lg-4">
                                <datepicker id="startTime" option="datetimeOption" format="L HH:mm" ng-model="AddModel.StartTime"></datepicker>
                            </div>
                            <label class="col-lg-1 control-label"><b style="color:red;">*</b>有效期结束时间</label>
                            <div class="col-lg-4">
                                <datepicker id="startTime" option="datetimeOption" format="L HH:mm" ng-model="AddModel.EndTime"></datepicker>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-lg-1 control-label"><b style="color:red;">*</b>安全措施</label>
                            <div class="col-lg-9" style="padding-left:20px;">
                                <label class="checkbox" ng-repeat="x in SolutionList">
                                    <input type="checkbox" id="chk_solution_{{x.Id}}" name="IsPublic">{{x.SolutionContent}}
                                </label>
                                <input type="text" ng-model="AddModel.OtherSolution" style="width:100px;border:none;border-bottom:1px solid grey;" />
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="inputStandard" class="col-lg-1 control-label"><b style="color:red;">*</b>上传附件</label>
                            <div class="col-lg-9">
                                <input type="file" ngf-select ng-model="doc.Files" name="docfiles" id="docfiles" class="file" initialPreviewAsData="true" data-show-remove="true" data-show-preview="true" showCancel="false" data-show-upload="false" multiple>
                            </div>
                        </div>
                    </form>
                </div>
                <div class="panel-footer">
                    <div class="row">
                        <div class="col-lg-1"></div>
                        <div class="col-lg-1">
                            <button type="button" class="btn btn-default" ng-click="SaveFireOperateForm(AddModel,0,1);">保存</button>
                        </div>
                        <div class="col-lg-1">
                            <a data-toggle="modal" class="btn btn-primary" href="#NoticeModal">提交</a>
                        </div>
                        <div class="col-lg-1">   <a href="FireOperateFormPageList?page={{page}}" class="btn btn-warning">返回</a></div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <div class="modal fade" id="AddModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
        <div class="modal-dialog" style="min-width:985px;">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                    <h2 class="modal-title">添加施工单位</h2>
                </div>
                <div class="modal-body">
                    <form class="form-horizontal" role="form">
                        <div class="form-group">
                            <label class="col-sm-2 control-label">施工单位名称</label>
                            <div class="col-lg-5">
                                <input type="text" class="form-control" placeholder="施工单位名称" ng-model="AddCompany.CompanyName">
                            </div>
                        </div>
                    </form>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal" id="btn_close">关闭</button>
                    <button type="button" class="btn btn-primary" ng-click="AddConstructionCompany(AddCompany);">提交</button>
                </div>
            </div>
        </div><!-- /.modal-dialog -->
    </div><!-- /.modal -->

    <div class="modal fade" id="AddFireOperator" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
        <div class="modal-dialog" style="min-width:985px;">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                    <h2 class="modal-title">添加动火人</h2>
                </div>
                <div class="modal-body">
                    <form class="form-horizontal" role="form">
                        <div class="form-group">
                            <label class="col-sm-2 control-label">姓名</label>
                            <div class="col-lg-5">
                                <input type="text" class="form-control" placeholder="动火人姓名" ng-model="AddFireOperatorModel.WorkerName">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">证件号</label>
                            <div class="col-lg-5">
                                <input type="text" class="form-control" placeholder="动火证件号" ng-model="AddFireOperatorModel.IdCardNo">
                            </div>
                        </div>
                    </form>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal" id="btn_close2">关闭</button>
                    <button type="button" class="btn btn-primary" ng-click="AddFireOperator(AddFireOperatorModel);">提交</button>
                </div>
            </div>
        </div><!-- /.modal-dialog -->
    </div><!-- /.modal -->

    <div class="modal fade" id="MapModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
        <div class="modal-dialog" style="min-width:985px;">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                    <h2 class="modal-title">厂区地图</h2>
                </div>
                <div class="modal-body">
                    <div class="div-relative" id="mapContent">
                        <div id="location" style="left:50%;top:50%;">
                            <i class="fa fa-map-marker"></i>
                        </div>
                        <img src="~/Bussiness/img/pvgmap.jpg" width="950" ng-show="AddModel.FactoryAreaId=='1'" />
                        <img src="~/Bussiness/img/dcArea.jpg" width="950" ng-show="AddModel.FactoryAreaId=='2'" />
                        <div ng-repeat="location in LocationList">
                            <div class="div-a" ng-style="{'left':location.X+'%','top':location.Y+'%'}">
                                <div style="font-size:12px; border-radius:4px;cursor:pointer;">
                                    <a class="titlediv" style="color:gainsboro;" title="{{location.BuildingName}}">{{location.SimpleName}}</a>
                                </div>
                            </div>
                        </div>
                    </div>
                    <input type="hidden" id="h_XAxis" value="0" />
                    <input type="hidden" id="h_YAxis" value="0" />
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                    <button type="button" class="btn btn-primary" data-dismiss="modal" ng-click="SelectPosition(CurrentLocationModel)">确定</button>
                </div>
            </div>
        </div><!-- /.modal-dialog -->
    </div><!-- /.modal -->


    <div class="modal fade" id="NoticeModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
        <div class="modal-dialog" style="min-width:985px;">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                    <h2 class="modal-title">安全承诺</h2>
                </div>
                <div class="modal-body" style="height:500px;overflow-y:scroll;">
                    本人保证提交内容真实、准确完整，不存在虚假记载、误导性陈述或重大遗漏，并承担相应的法律责任。
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal" id="btn_close_notice">关闭</button>
                    <button type="button" class="btn btn-primary" ng-click="SaveFireOperateForm(AddModel,1,1);">我已阅读并同意以上事项</button>
                </div>
            </div>
        </div><!-- /.modal-dialog -->
    </div><!-- /.modal -->
</div>

@section Js{
    <script src="~/Bussiness/js/libs/upload.js"></script>
    <script src="~/Bussiness/js/pg/Construction.js?v=@DateTime.Now.ToString("yyMMddHHmm")"></script>
    <script src="~/Bussiness/js/libs/moment.min.js"></script>
    <script src="~/Bussiness/js/libs/locales/date/zh-cn.js"></script>
    <script src="~/Bussiness/js/libs/bootstrap-datetimepicker.min.js"></script>
    <script src="~/Bussiness/js/libs/angularjs-datepicker.js"></script>
    <script src="~/Bussiness/js/libs/fileinput.js"></script>
    <script src="~/Bussiness/js/libs/zh.js"></script>
    <script>
        $('#docfiles').fileinput({
            language: 'zh'
        });

        $("#mapContent").mousedown(function (e) {
            var width = $("#mapContent").width();
            var height = $("#mapContent").height();
            mouseX1 = (e.pageX - $("#mapContent").offset().left) / width;
            mouseY1 = (e.pageY - $("#mapContent").offset().top) / height;
            $("#location").css({ 'left': mouseX1 * 100 + '%', 'top': mouseY1 * 100 + '%' });
            $("#h_XAxis").val(mouseX1);
            $("#h_YAxis").val(mouseY1);
        });
    </script>
}